﻿<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" />
  <xsl:template match="/">
  
      SELECT * FROM [<xsl:value-of select="/Schema/@Owner" />].[<xsl:value-of select="/Schema/@TableName" />] <xsl:if test="Schema/@IsNoLock='1'">  WITH(NOLock)</xsl:if>
      WHERE<xsl:for-each select="Column">
        [<xsl:value-of select="FKCOLUMN_NAME" />]=@<xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()"> AND </xsl:if>
      </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>